<template>
	<view class="my-page">
		<u-navbar title="我的" bgColor="rgba(255,255,255,0.0)" left-icon="" :placeholder="true">
		</u-navbar>
		<view class="head">
			<view class="head-top">
				<view class="portrait">
					<image :src="userinfo.avatar" mode=""></image>
				</view>
				<view class="top-right">
					<view class="name">
						ID：{{userinfo.username}}
					</view>
				</view>
			</view>
		</view>
		<view class="info-list">
			<view class="ability">
				<view class="ability-item" v-for="(item,index) in abilityList" :key="index"
					@click="gonavto(item.url)">
					<image :src="item.img" mode="aspectFill"></image>
					<view class="ability-right">
						<view class="ability-text">
							{{item.text}}
						</view>
						<u-icon name="arrow-right" color="#706D6C" size="16"></u-icon>
					</view>
				</view>
			</view>
			<view class="btn">
				<u-button color="linear-gradient( 90deg, #FE8A03 0%, #FA5900 100%)" type="primary" text="退出"
					@click="goLogin" size="large"></u-button>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				userinfo: {},
				abilityList: [{
						text: '安全设定',
						img: '../../static/my/ability1.png',
						url: '/pages/my/security/index',
						type: 0
					},
					{
						text: '账户管理',
						img: '../../static/my/ability2.png',
						url: '/pages/my/account/receive/index',
						type: 1
					},
					// {
					// 	text: '店铺设定',
					// 	img: '../../static/my/ability3.png',
					// 	url: '/pages/my/shop/index',
					// 	type: 1
					// },
					{
						text: '基本设定',
						img: '../../static/my/ability4.png',
						url: '/pages/my/basic/index',
						type: 0
					},
					{
						text: '下级管理',
						img: '../../static/my/ability5.png',
						url: '/pages/my/below/index',
						type: 0
					}
				]
			}
		},
		onLoad() {
			this.getuserinfo()
		},
		methods: {
			getuserinfo() {
				this.$Request({
					method: 'GET',
					url: '/api/getInfo',
					data: {},
					ismsg: false,
				}).then(res => {
					if (res.code == 200) {
						this.userinfo = res.user
					}
				})
			},
			goLogin() {
				uni.showModal({
					title: '退出登录',
					content: '确定要退出吗',
					success: function(res) {
						if (res.confirm) {
							uni.clearStorageSync();
							uni.reLaunch({
								url: '/pages/login/index'
							})
						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				})
			},
			gonavto(url){
				uni.navigateTo({
					url:url
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.my-page {
		min-height: calc(100vh - 91rpx);
		background-image: url('../../static/goods/top-bg.png');
		background-size: 100% 561rpx;
		background-repeat: no-repeat;

		.dividend {
			text-align: center;

			.dividend-title {
				font-size: 30rpx;
			}

			.dividend-tips {
				color: red;
				font-size: 24rpx;
				margin-top: 10rpx;
			}

			.dividend-item {
				display: flex;
				justify-content: space-between;
				align-items: center;
				margin-top: 30rpx;
				text-align: left;

				.item-title {
					width: 150rpx;
					font-size: 26rpx;
					color: #999;
				}
			}

		}

		.head {
			padding: 60rpx 30rpx 30rpx 30rpx;

			.head-top {
				display: flex;
				align-items: center;

				.portrait {
					margin-right: 40rpx;

					image {
						width: 150rpx;
						height: 150rpx;
						border-radius: 50%;
					}
				}

				.top-right {
					color: #333333;

					.name {
						font-size: 28rpx;
						font-weight: bold;
					}
				}
			}
		}

		.info-list {
			padding: 0 30rpx;

			.ability {
				margin-top: 20rpx;
				box-shadow: 0rpx 0rpx 16rpx 1rpx rgba(0, 0, 0, 0.08);
				padding: 30rpx 30rpx 10rpx 30rpx;
				background-color: #ffffff;
				border-radius: 30rpx;

				.ability-item {
					display: flex;
					align-items: center;
					padding-bottom: 20rpx;
					margin-bottom: 30rpx;
					border-bottom: 1rpx solid #F0F0F0;

					image {
						width: 40rpx;
						height: 40rpx;
					}

					.ability-right {
						width: 90%;
						margin-left: 30rpx;
						display: flex;
						justify-content: space-between;


						.ability-text {
							font-size: 28rpx;
							color: #000000;
						}
					}
				}

				.ability-item:last-child {
					border-bottom: none;
					margin-bottom: 0;
				}
			}

			.btn {
				border-radius: 30rpx;
				overflow: hidden;
				margin-top: 40rpx;
			}
		}
	}
</style>